package com.bosicen.crm.web.controller.orders;

import java.io.IOException;
import java.io.Writer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bosicen.crm.dao.entity.OrderDetail;
import com.bosicen.crm.service.orders.OrdersServiceImpl;
import com.bosicen.crm.tools.CalculateOrder;
import com.google.gson.Gson;

@Controller
@RequestMapping("/calculate")
public class CalculateController {

	@Autowired
	CalculateOrder calculateorder;
	/****
	 * 计算门的尺寸
	 * @param detail
	 * @param writer
	 */
	@RequestMapping(value="/doors")
	public void Calculate_Doors(OrderDetail detail,Writer writer){
		Gson gson = new Gson();
		try {
			detail=calculateorder.Calculate_Doors(detail);
		} catch (Exception ex) {
			ex.printStackTrace();
		}finally {
			try {
				writer.write(gson.toJson(detail));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
	/****
	 * 计算门套的尺寸
	 * @param detail
	 * @param writer
	 */
	@RequestMapping(value="/loop")
	public void Calculate_Loops(OrderDetail detail,Writer writer){
		Gson gson = new Gson();
		try {
			detail=calculateorder.Calculate_Loops(detail);
		} catch (Exception ex) {
			ex.printStackTrace();
		}finally {
			try {
				writer.write(gson.toJson(detail));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
}
